
 /**
 * PagerFilter.java.java.
 * User: BrianChen Date: 2012-7-4 下午05:35:49
 *
 * Copyright (c) 2009 Hewlett-Packard Development Company, L.P.
 * All rights reserved.
 */
package com.collapsar.core.aop.filter;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

/**
 * <pre>
 * REVISIONS: 
 * Version 	Date 		Author 			Description
 * ------------------------------------------------------------------- 
 * 1.0 		2012-7-4 	BrianChen 	1. Created this class. 
 * </pre>
 * 
 * @author BrianChen
 * @date 2012-7-4 下午05:35:49
 * @version 1.0
 * @see
 * 
 */
public class PagerFilter implements Filter{
	//private static final Logger logger = LoggerFactory.getLogger(PagerFilter.class);
	
	@Override
	public void destroy() {
		// TODO Auto-generated method stub 
	}

	@Override
	public void doFilter(ServletRequest request, ServletResponse response,
			FilterChain chain) throws IOException, ServletException {
		
//		HttpServletRequest hreq = (HttpServletRequest)request;
//		logger.info("# page.offset="+this.getOffset(hreq)+", page.size="+this.getPageSize());
//		SystemContext.setOffset(this.getOffset(hreq));
//		SystemContext.setPageSize(this.getPageSize());
//		try{
//			chain.doFilter(request, response);
//		}catch(Exception ex){
//			ex.printStackTrace();
//		}finally{
//			SystemContext.removeOffset();
//			SystemContext.removePageSize();
//		}
	}

	@Override
	public void init(FilterConfig arg0) throws ServletException {
		// TODO Auto-generated method stub 
	}
//	
//	private int getOffset(HttpServletRequest request){
//		int offset = 0;
//		try{
//			String temp = request.getParameter("pager.offset");
//			if(StringUtils.isNotBlank(temp)){
//				offset = Integer.parseInt(temp);
//			}
//		}catch(NumberFormatException ex){
//			ex.printStackTrace();
//		}
//		return offset;
//	}
//	
//	private int getPageSize(){
//		return 2;
//	}

}

